<!-- 修改密码 -->
<template>
  <div class="modify-password-dialog">
    <el-dialog
      title="修改密码"
      :visible="myVisible"
      width="350px"
      @close="close">
      <el-form label-width="90px">
        <el-form-item label="原密码">
          <el-input type="password" v-model="modify.oldPassword"></el-input>
        </el-form-item>
        <el-form-item label="新密码">
          <el-input type="password" v-model="modify.newPassword"></el-input>
        </el-form-item>
        <el-form-item label="确认新密码">
          <el-input type="password" v-model="modify.confirmNewPassword"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="sure">确 定</el-button>
        <el-button @click="close">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
// import {
//   ElDialog,
//   ElForm,
//   ElFormItem,
//   ElButton,
//   ElInput
// } from '@eui'
import {
  updatePassword
} from '../api/loginApi'
export default {
  // components: {
  //   ElDialog,
  //   ElForm,
  //   ElFormItem,
  //   ElButton,
  //   ElInput
  // },
  props: {
    visible: {
      type: Boolean,
      default: false
    }
  },
  data () {
    return {
      myVisible: this.visible,
      modify: {}
    }
  },
  watch: {
    visible (value) {
      this.myVisible = value
    },
    myVisible (value) {
      this.$emit('visibleChange', value)
    }
  },
  methods: {
    async sure () {
      const res = await updatePassword(this.modify)
      if (res.status === 200) {
        this.$notify({
          title: '成功',
          message: res.msg,
          type: 'success'
        })
        this.close()
      } else {
        this.$notify.error({
          title: '提示',
          message: res.msg
        })
      }
    },
    close () {
      this.myVisible = false
    }
  }
}
</script>
